import http from "@/common/http/index.js";

/*
 * 获取点赞数
 * topic_id:   主题ID, 如景区ID、文章ID
 * topic_type: 主题类型; 0: 景区, 1: 文章
 */
function getNum(topic_id, topic_type) {
  let params = { topic_id: topic_id, topic_type: parseInt(topic_type) };
  return http.get("/like/num", params);
}

/*
 * 用户是否点赞
 * topic_id:   主题ID, 如景区ID、文章ID
 * topic_type: 主题类型; 0: 景区, 1: 文章
 */
function queryLike(topic_id, topic_type) {
  let params = { topic_id: topic_id, topic_type: parseInt(topic_type) };
  return http.get("/like", params);
}

/*
 * 切换用户点赞状态, 返回点赞数
 * topic_id:   主题ID, 如景区ID、文章ID
 * topic_type: 主题类型; 0: 景区, 1: 文章
 */
function changeLike(topic_id, topic_type) {
  let params = { topic_id: topic_id, topic_type: parseInt(topic_type) };
  return http.post("/like/change", params);
}


export default {
  getNum,
  queryLike,
  changeLike,
};
